<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>订单查询</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <link href="<%=path %>/hplus/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path %>/hplus/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="<%=path %>/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/animate.min.css" rel="stylesheet">
    <link href="<%=path %>/hplus/css/style.min862f.css?v=4.1.0" rel="stylesheet">
        <link href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
    
    <style>
        .col-sm-1{
            padding-right: 0;
        }
        input.uploadFile{
            position: absolute;
            opacity: 0;
            width: 100%;
            height: 100%;
            left: 0;
            top: 0;
            line-height: 0;
            padding-left: 0;
            margin-left: 0;
        }

        .uploadBtn{
            width: 60px;
            display: inline-block;
            background: #1ab394;
            color: #fff;
            border-radius: 3px;
            height: 36px;
            line-height: 36px;
            border: none;
            font-size: 14px;
        }
        .s_address{
            height: 340px;
            background:#eee;
        }
        .red{
            color: red;
            margin-right: 5px;
        }
		body{
			font-size:16px;
			
		}
		.inner_table td{  
        border-top: 0;  
        border-right: 0;  
        border-bottom: 1px solid #999;  
        border-left: 0;  
    } 
	   .inner_table tr.lastrow td {  
        border-bottom: 0;  
    } 
  	ol{
  		list-style:none;
  	}
  	li{
  		list-style:none;
  	}
    </style>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content" >
        <div class="ibox-content">
		 <form method="post" class="form-horizontal"  id='share_image' enctype='multipart/form-data'>
			<div class="col-sm-2"></div>
			<div class="form-group">
					<label class="col-sm-1 control-label">小票单号:</label>
				<div class="col-sm-3">
					<input type="text" class="form-group form-control" id="order_number"/>		
				</div>
			</div>
			<div class="col-sm-2"></div>
			<div class="form-group">					
                    <label class="col-sm-1 control-label">门&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;店:</label>
                    <div class="col-sm-2">
                       <select class="form-group form-control" id="store_id">
						<option value="50">安康大药店</option>
						<option value="46">门店2</option>
					   </select>
                    </div>
					<label class="col-sm-1 control-label">款&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;员:</label>
                    <div class="col-sm-2">
                       <select class="form-group form-control" id="cashier_id">
						<option value="1">义峰</option>
						<option value="2">银子</option>
					   </select>
                    </div>
                </div>
				<div class="col-sm-2"></div>
				<div class="form-group">
					 <label class="col-sm-1 control-label">开始时间:</label>
					 <div class="col-sm-2">
						   <input type="date" class="form-group form-control" id="startDate"/>		
					 </div>
					 <label class="col-sm-1 control-label">结束时间:</label>
					  <div class="col-sm-2">
						   <input type="date" class="form-group form-control" id="endDate"/>		
					  </div>
                </div>
				<div class="col-sm-4"></div>
				<div class="form-group">
					 <label class="col-sm-1 control-label"><input type="checkbox" id="term1">注册新会员</label>
					 <label class="col-sm-1 control-label"><input type="checkbox" id="term2">录入体质标签</label>
                </div>
				<div class="form-group">
					<div class="col-sm-3"></div>
                    <div class="col-sm-3 col-sm-offset-1">
						<div class="col-sm-1"></div>
						<button type="button" class=" btn btn-primary k_verify" id="commit">查询</button>
						<div class="col-sm-1"></div>
						<button type="button" class=" btn btn-outline btn-primary" id="close" style="margin-right:20px;" organizationImg="">重置</button>
                    </div>
                </div> 
				<div class="form-group">
					<div class="col-sm-1"></div>
					<div class="col-sm-10">
						<table class="table table-bordered" id="myTable">
							<thead>
							 <tr>
								<th>小票单号</th>
								<th>交易时间</th>
								<th>门店名称</th>
								<th>款员</th>
								<th>预购商品</th>
								<th>购买数量</th>
								<th>总金额</th>
								<th>注册新会员</th>
								<th>体质标签</th>
							 </tr>
							</thead>
							<tbody>
								<!--  <tr>
									<td>D00001</td>
									<td>2017-10-11</td>
									<td>08:10:45</td>
									<td>康寿堂大望路店</td>
									<td>晓虎</td>
									<td>蒲地兰消炎片</td>
									<td>1盒</td>
									<td>50</td>
									<td>是</td>
									<td>高血压</td>
								</tr>
								<tr>
									<td>D00002</td>
									<td>2017-10-11</td>
									<td>08:10:45</td>
									<td>康寿堂大望路店</td>
									<td>晓虎</td>
									<td>蒲地兰消炎片</td>
									<td>1盒</td>
									<td>50</td>
									<td>是</td>
									<td>高血压</td>
								</tr>
								-->
							</tbody>
						</table>
					</div>
				</div>
			</form>
		</div>
    </div> 
    <a href="javaScript:void(0)" id="time">点击</a>     
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jsKnob/jquery.knob.js"></script>
    <script src="<%=path%>/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/prettyfile/bootstrap-prettyfile.js"></script>
    <script src="<%=path%>/hplus/js/plugins/switchery/switchery.js"></script>
    <script src="<%=path%>/hplus/js/plugins/ionRangeSlider/ion.rangeSlider.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/iCheck/icheck.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/metisMenu/jquery.metisMenu.js"></script>
    <script src="<%=path%>/hplus/js/plugins/colorpicker/bootstrap-colorpicker.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/clockpicker/clockpicker.js"></script>
    <script src="<%=path%>/hplus/js/plugins/cropper/cropper.min.js"></script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
    <script src="<%=path%>/hplus/js/demo/form-advanced-demo.min.js"></script>
	<script src="<%=path%>/hplus/js/plugins/suggest/bootstrap-suggest.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
    <script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
	<script type="text/javascript" src="<%=path%>/bm/js/dialog.js"></script>
	<script type="text/javascript" src="<%=path%>/js/marketing/public.js"></script>
    <script>
	    var path = "<%=path%>";
	    var myDataTable;
		var orderNumber;
		var storeId;
		var cashierId;
		var startDate;
		var endDate;
		//0代表都不查 1代表注册会员 2 代表录入体质 3代表全选
		var flag=0;
	    var access_token=$.cookie('access_token');
	   	var cid=$.cookie('cid');
	   	var uid=$.cookie('uid');
	   	var id=getQueryString("id");
        function dataTable(){
        	return $('#myTable').DataTable({
        		processing: true,
        		ordering: false,
        		searching: false,
        		info: true,
        		autoWidth: true,
        		lengthChange: false,
        		"order": [[ 2, "desc" ]],
        	    language: {
        	    	emptyTable: '<div id="content_empty"  class="form-group white-bg" style="text-align:center;padding:200px 0;margin:0;">   <p>暂无点击数据</p></div>',
        	    	info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
        			infoEmpty: '没有数据',
        			lengthMenu: '每页显示 _MENU_ 条记录',
        			loadingRecords: '正在加载数据....',
        			processing: '正在处理数据....',
        			zeroRecords: '没有找到匹配的记录',
        			paginate: {
        				first: '首页',
        				previous: '前页',
        				next: '后页',
        				last: '尾页'
        			}
        	    },
        	    order: [[1,'desc']],
        		pageLength: 6,
        	    pagingType: 'full_numbers',        	     
        	    columns: func_columns(),
        	     columnDefs: [{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].goodsName+"</li>";
        				}           
        				return result;
                    },
        			targets: 4
        		},{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].purchaseQuantity+"</li>";
        				}           
        				return result;
                    },
        			targets: 5
        		},{
        			render: function(data, type, full) {
        				var json=JSON.parse(data);
        				var result='<ol>';
        				for(var i=0;i<json.length;i++){
        					result+="<li>"+json[i].tagName+"</li>";
        				}           
        				return result;
                    },
        			targets: 8
        		}], 
        	    serverSide: true,
        	    ajax: {
        	    	contentType: 'text/plain;charset=utf-8',
        	    	type: 'POST',
        	    	url: func_AjaxUrl(),
        	    	data: function(d){
        				d.extra_search = func_ajaxData();
        				return JSON.stringify(d);
        	    	}
        	    	
        			
        	    }
        	});
        	 function func_AjaxUrl(){
             	return path+"/ser/order/orderList";
             }
        	 /**
        	  *	后台查询条件
        	  */
        	 function func_ajaxData(){
        	 	var jsonObject = new Object();
        	 	if(orderNumber!=null&&orderNumber!=""){
           		 jsonObject.orderNumber=orderNumber;
           		 }
           		 if(storeId!=null&&storeId!=""){
           			 jsonObject.storeId=storeId;
           		 }
           		 if(cashierId!=null&&cashierId!=""){
           			 jsonObject.cashierId=cashierId;
           		 }
           		 if(startDate!=null&&startDate!=""){
           			 jsonObject.startDate=startDate;
           		 }
           		 if(endDate!=null&&endDate!=""){
           			 jsonObject.endDate=endDate;
           		 }
           		 jsonObject.flag=flag;
        	 	return jsonObject;
        	 }
             /**
              *	设置列名，对应后台
              */
             function func_columns(){
             	var jsonArr = [
             		{"data":"order_number"},
             		{"data":"trade_time"},
             		{"data":"store_name"},
             		{"data":"cashier_name"},
             		{"data":"goods_name"},
             		{"data":"purchase_quantity"},
             		{"data":"order_price"},
             		{"data":"flag"},
             		{"data":"tag_name"}
             	];
//              	JSON.parse()
             	return jsonArr;
             }
        }
        $(function(){      	
        	//$('#myTable').DataTable();   
        	myDataTable=dataTable();
        	$("#commit").click(function(){
				storeId=$("#store_id").val();
				cashierId=$("#cashier_id").val();
				startDate=$("#startDate").val();
				endDate=$("#endDate").val();
				orderNumber=$("#order_number").val();
				if($("#term1").is(":checked")){
					flag=1;
				}else if($("#term2").is(":checked")){
					flag=2;
				}else{
					flag=0;
				} 
				if($("#term1").is(":checked")&&$("#term2").is(":checked")){
					flag=3;
				}
				console.log(storeId+"---"+cashierId+"---"+startDate+"----"+endDate+"-----"+orderNumber);
				myDataTable.ajax.reload();
			});
        	$("#close").click(function(){
        		window.location.reload();
        	})
        });
		function getOrder(id){
			window.open(path+"/ser/ui/orderDetail?id="+id);
        }	
		function getChange(){
			var url=path+"/ser/order/getChange";
			$.post(url,{
				"access_token" : access_token,
        		"cid" : cid,
        		"uid" : uid},
        		function(data){        		
        		var json=JSON.parse(data);
        		console.log(data);
        		 if(json.id!=null){
        			 getOrder(json.id);
        		 }       		
			});
		}
		$("#time").click(function(){
			getChange();
		})
        //setInterval(getChange,5000);
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>
</html>
